package cn.dzhang.spring.boot.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Size;

@Entity
@Table(name = "tbl_device_type")
public class DeviceType extends ModelBase {

	private static final long serialVersionUID = 2587464278478878097L;
	@Column(nullable = true, length = 100)
	@Size(min = 2, max = 100)
	private String name;
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
	private DeviceCategory category;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public DeviceCategory getCategory() {
		return category;
	}

	public void setCategory(DeviceCategory category) {
		this.category = category;
	}

	@Override
	public String toString() {
		return String.format("DeviceType [name=%s, category=%s]", name,
				category);
	}

}
